using System.Net.WebSockets;

namespace sgf.server
{
    public class WebSocketConnectionHandler(
        Action<NetChannel> onConnect,
        Action<long, byte[]> onMessage,
        Action<NetChannel> onDisConnect)
    {
        public virtual async Task OnConnectedAsync(WebSocket socket, string clientAddress)
        {
            LogMgr.Info($"new websocket {clientAddress} connect...");
            NetChannel channel = new WebSocketChannel(socket, clientAddress, onMessage);
            onConnect(channel);
            await channel.StartAsync();
            onDisConnect(channel);
        }
    }
}